//
//  FocusDoctorViewController.m
//  QuickCure
//
//  Created by haoge on 16/9/10.
//  Copyright © 2016年 haoge. All rights reserved.
//

#define MAS_SHORTHAND
#define MAS_SHORTHAND_GLOBALS
static NSString * reuseId = @"doctor";

#import "FocusDoctorViewController.h"
#import "DocotorInfoViewController.h"
#import "DocotorDescribeCell.h"
#import "DoctorModel.h"
#import <Masonry.h>


@interface FocusDoctorViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView * tableView;
@property(nonatomic,strong)NSArray * doctorInfo;

@end


@implementation FocusDoctorViewController

-(NSArray *)doctorInfo{
    if (!_doctorInfo){
        
        DoctorModel * model1 = [[DoctorModel alloc]init];
        model1.name = @"赵医生";
        model1.hospital=@"上海协和医院";
        model1.professional=@"主治医师";
        model1.flower=@"256";
        model1.order=@"17";
        model1.flag=@"114";
        model1.matchPercent=@"97%";
        
        
        DoctorModel * model2 = [[DoctorModel alloc]init];
        model2.name = @"王医生";
        model2.hospital=@"上海第九医院";
        model2.professional=@"院长";
        model2.flower=@"299";
        model2.order=@"57";
        model2.flag=@"123";
        model2.matchPercent=@"89%";
        
        DoctorModel * model3 = [[DoctorModel alloc]init];
        model3.name = @"张医生";
        model3.hospital=@"上海长征医院";
        model3.professional=@"副主治医师";
        model3.flower=@"176";
        model3.order=@"27";
        model3.flag=@"74";
        model3.matchPercent=@"80%";
        
        DoctorModel * model4 = [[DoctorModel alloc]init];
        model4.name = @"刘医生";
        model4.hospital=@"上海九州医院";
        model4.professional=@"主治医生";
        model4.flower=@"156";
        model4.order=@"45";
        model4.flag=@"114";
        model4.matchPercent=@"88%";
        
        DoctorModel * model5 = [[DoctorModel alloc]init];
        model5.name = @"赵医生";
        model5.hospital=@"上海现代医院";
        model5.professional=@"高级医师";
        model5.flower=@"99";
        model5.order=@"12";
        model5.flag=@"67";
        model5.matchPercent=@"85%";
        
        _doctorInfo = @[model1,model2,model3,model4,model5];
    
    }
    
    return _doctorInfo;
}

- (void)viewDidLoad {
    
    [super viewDidLoad];

    //tableView
    self.tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[DocotorDescribeCell class] forCellReuseIdentifier:@"cell"];
    self.tableView.backgroundColor = [UIColor colorWithRed:0.9511 green:0.9511 blue:0.9511 alpha:1.0];
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.estimatedRowHeight = 100 ;

    [self.view addSubview:self.tableView];
  
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.equalTo(self.view);
        make.width.equalTo(self.view);
        
    }];
    
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.doctorInfo.count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    DocotorDescribeCell * doc = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    doc.model = self.doctorInfo[indexPath.section];
    return doc;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    DocotorInfoViewController * vc =[[DocotorInfoViewController alloc]init];
    vc.title =@"医生基本信息";
    vc.model=self.doctorInfo[indexPath.section];
    [self.navigationController pushViewController:vc animated:YES];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 15;
}

@end
